package com.miplus.ccrm.core.service.crd;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.yulichang.base.MPJBaseServiceImpl;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.miplus.ccrm.common.JSysUser;
import com.miplus.ccrm.common.JUsrPerm;
import com.miplus.ccrm.core.controller.vo.credit.ConCustomerAccountResVo;
import com.miplus.ccrm.core.controller.vo.credit.CrdCardReqVo;
import com.miplus.ccrm.core.controller.vo.credit.CrdCardResVo;
import com.miplus.ccrm.core.pojo.ConCustomerAccount;
import com.miplus.ccrm.core.mapper.ConCustomerAccountMapper;
import org.springframework.stereotype.Service;

/**
* @author Yaohui
* @description 针对表【con_customer_account(客户账户信息文件)】的数据库操作Service实现
* @createDate 2024-11-16 18:50:56
*/
@Service
public class ConCustomerAccountServiceImpl extends MPJBaseServiceImpl<ConCustomerAccountMapper, ConCustomerAccount>
    implements ConCustomerAccountService{

    @Override
    public IPage<ConCustomerAccountResVo> accountPage(JSysUser user, CrdCardReqVo paras) {

        String cardstar= JUsrPerm.getPermission(user,JUsrPerm.DISSTAR_CARD);
        String phnstar = JUsrPerm.getPermission(user,JUsrPerm.DISSTAR_PHN);
        String $usrid=user.getUsrid();

        return selectJoinListPage(new Page<>(paras.getPageNum(), paras.getPageSize()), ConCustomerAccountResVo.class,
                new MPJLambdaWrapper<>(ConCustomerAccount.class)
                        .selectAs(String.format("fi_starSecu('%s','%s',t.brank_card_no,'%s')",$usrid,JUsrPerm.DISSTAR_CARD,cardstar), ConCustomerAccountResVo::getBrankCardNo)
                        .selectAs(String.format("fi_starSecu('%s','%s',t.user_phone,'%s')",$usrid,JUsrPerm.DISSTAR_PHN,phnstar), ConCustomerAccountResVo::getUserPhone)
                        .select(ConCustomerAccount::getAccountId,ConCustomerAccount::getCustomernumber,ConCustomerAccount::getBrankName,
                                ConCustomerAccount::getBindingTimes)
                        .eq(ConCustomerAccount::getCustomernumber,paras.getCustid())

        );
    }
}




